<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div style="display: flex">
      <div style="flex: 0 0 200px">
        <div>
          <button id="btnImportNode">importNode content1</button>
          <button id="btnAdoptNode">adoptNode content2</button>
        </div>
        <div id="container1"></div>
      </div>
      <div>
        <iframe src="./4.0 iframe.html" id="ifr"></iframe>
      </div>
    </div>

    <script>
      // importNode  true代表导入后代节点
      btnImportNode.addEventListener("click", function () {
        const node = document.importNode(
          ifr.contentWindow.document.querySelector("#content1"),
          true
        );
        container1.append(node);
      });

      // adoptNode
      btnAdoptNode.addEventListener("click", function () {
        const node = document.adoptNode(ifr.contentWindow.document.querySelector("#content2"));
        container1.append(node);
      });
    </script>
  </body>
</html>
